<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- ⼆进制转⼗进制，⼗进制转⼆进制，各编写⼀个函数。
    输入二进制数字调用函数转成十进制，输入十进制数字调用函数转成二进制 -->
    <script>
      function res() {
        const decimalNum = 10 //注意此处是Number类型
        console.log(decimalNum.toString(2)) // "1010"
      }

      function num() {
        var num1 = '1010'
        var num2 = parseInt(num1, 2) // 10
        console.log(num2)
      }
    </script>
  </body>
</html>
